package com.controller;

import com.entity.User;
import com.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author m
 * @date 2022/12/26 - 16:39
 */


@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/api")
public class UserController {

    @Autowired
    UserRepository userRepository;

    @PostMapping("/user")
    public ResponseEntity<User> addUser(@RequestBody User user){
        System.out.println(user);
        User user1 = userRepository.save(user);
        return new ResponseEntity<>(user1, HttpStatus.CREATED);
    }

}
